﻿using System.Configuration;
using System.Web.Mvc;
using System.Web.Routing;

namespace MvcWechat
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            var startPage= ConfigurationManager.AppSettings["StartPage"];
            if (startPage.ToLower() == "wap")
            {
                //手机网站为默认页
                routes.MapRoute(
                     name: "Default",
                     url: "{controller}/{action}/{id}",
                     defaults: new { controller = "Customer", action = "Index", id = UrlParameter.Optional },
                      namespaces: new string[] { "MvcWechat.Areas.Wap.Controllers" }
                 ).DataTokens.Add("Area", "Wap");
            }
            else
            {
                //web网站为默认页
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Web", action = "Index", id = UrlParameter.Optional },
                     namespaces: new string[] { "MvcWechat.Controllers" }
                );
            }
        }
    }
}